package com.pink.entity.vo;

import org.springframework.http.HttpStatus;

public record ResponseVo<T>(int code, String state, String message , T data){
    public static <T> ResponseVo<T> success(T data){ return new ResponseVo<>(200,"success","请求成功！",data);}
    public static <T> ResponseVo<T> success(String message){ return new ResponseVo<>(200,"success",message,null);}
    public static <T> ResponseVo<T> success(String message,T data){ return new ResponseVo<>(200,"success",message,data);}
    public static <T> ResponseVo<T> fail(String message){ return new ResponseVo<>(500,"fail",message,null);}
    public static <T> ResponseVo<T> fail(String message,T data){ return new ResponseVo<>(500,"fail",message,data);}
    public static <T> ResponseVo<T> fail(int code,String message){ return new ResponseVo<>(code,"fail",message,null);}
    public static <T> ResponseVo<T> fail(int code,String message,T data){ return new ResponseVo<>(code,"fail",message,data);}
    public static <T> ResponseVo<T> error(String message){ return new ResponseVo<>(500,"error",message,null);}
    public static <T> ResponseVo<T> error(String message,T data){ return new ResponseVo<>(500,"error",message,data);}

    public static ResponseVo<String> fail(HttpStatus httpStatus, String message) {
        return new ResponseVo<>(httpStatus.value(), "error", message, null);
    }
}
